package com.xieyingwangluo.yxpart.api;

import com.xieyingwangluo.yxpart.bean.EnrollDTO;
import com.xieyingwangluo.yxpart.bean.Result;
import com.xieyingwangluo.yxpart.entity.EnrollModel;
import com.xieyingwangluo.yxpart.logic.EnrollLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api(tags = "enroll接口")
@Controller
@RequestMapping(value = "/api/v1/enroll")
public class EnrollBaseRest extends BaseRest {
    @Autowired
    private EnrollLogic enrollLogic;

    //添加报名
    @ApiOperation(value = "添加报名", notes = "添加报名", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "part_id", value = "兼职id", required = true, dataType = "String", paramType = "form", defaultValue = "17689098789"),
            @ApiImplicitParam(name = "user_id", value = "用户编号", required = true, dataType = "String", paramType = "form", defaultValue = "0b6f0f71-a6ab-11e8-b52f-000c2984c921"),
            @ApiImplicitParam(name = "advantage", value = "个人优势", required = true, dataType = "String", paramType = "form", defaultValue = "有多个证书")
    })
    @ResponseBody
    @PostMapping(value = "/add")
    public Result add(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                      EnrollDTO enrollDTO
    ) {
        return enrollLogic.add(enrollDTO);
    }

    //查询报名信息
    @ApiOperation(value = "查询报名信息", notes = "查询报名信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "登陆用户id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selO")
    public Result selO(@RequestParam("noid") String noid) {
        return enrollLogic.selO(noid);
    }

    //模糊查询报名
    @ApiOperation(value = "模糊查询报名", notes = "模糊查询报名", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "报名id", required = false, dataType = "String", paramType = "query", defaultValue = ""),
            @ApiImplicitParam(name = "part_id", value = "兼职id", required = false, dataType = "String", paramType = "query", defaultValue = "17689098789"),
            @ApiImplicitParam(name = "userinfo_id", value = "用户信息编号", required = false, dataType = "String", paramType = "query", defaultValue = "0b6f0f71-a6ab-11e8-b52f-000c2984c921"),
            @ApiImplicitParam(name = "create_time", value = "报名时间", required = false, dataType = "String", paramType = "query", defaultValue = ""),
            @ApiImplicitParam(name = "advantage", value = "个人优势", required = false, dataType = "String", paramType = "query", defaultValue = "有多个证书")})
    @ResponseBody
    @GetMapping(value = "/selA")
    public Result selA(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       EnrollModel enrollModel) {
        return enrollLogic.selA(enrollModel);
    }

    //取消报名
    @ApiOperation(value = "取消报名", notes = "取消报名", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "登陆用户id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "part_id", value = "兼职id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/del")
    public Result del(@RequestParam("noid") String noid,
                      @RequestParam("part_id") String part_id) {
        return enrollLogic.del(noid, part_id);
    }
}
